home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- * The Unoffical Bastard Operator From Hell (B.O.F.H.)
- * Excuse Calendar V1.1
- *
- * (c) 1999 Robert Carr
- * rob@itsproven.com
- * www.itsproven.com
- *
- * This program is FREEWARE. Linux Rules.
- *
- * if you use the source, or the program, drop me a note. If have
- * written your own pilot program, include the source so others may learn
- * from your code.
- *
- * ---late
- ************************************************************************/
-
-
- #include "bofh.rsh"
- #include <System/SysAll.h>
- #include <UI/UIAll.h>
-
- #define TOTALEXCUSES 248
- #define MESSAGE_AT_Y 60 // Y position to start displaying messages
- #define WORD_WRAP_AT 140 // # of pixels to wrap text at
-
- #define appCreatorID 'Bofh'
- #define appPrefID 0x00
-
- DateType today;
- ULong secs;
-
-
- typedef struct {
- Word day;
- int version;
- Word lastExcuse;
- } prefs;
-
- prefs myprefs;
-
- static void EventLoop(void);
- static void StartApplication(void);
- static void StopApplication(void);
- static void DisplayNewExcuse(void);
- static void CheckDatabases(void);
- static void readPreferences(void);
- static void chopper(void *source, void *dest);
-
- static Boolean MainMenuHandler(EventPtr event);
- static Boolean MainFormHandleEvent(EventPtr event);
-
- char line1[80];
- char line2[80];
- char line3[80];
-
- char *pline1 = line1;
- char *pline2 = line2;
- char *pline3 = line3;
- char *pExcuse;
-
- // all the excuses. I think I should throw these into a separate PDB file.
- // oh well...next version.
-
- char excuses[TOTALEXCUSES][100] = {
-
- "Clock speed",
- "Solar flares",
- "Electromagnetic radiation from satellite debris",
- "Global warming",
- "Poor power conditioning",
- "Static buildup",
- "Doppler effect",
- "Hardware stress fractures",
- "Magnetic interference from money/credit cards",
- "Dry joints on cable plug",
- "We're waiting for [the phone company] to fix that line",
- "Sounds like a Windows problem, try calling Microsoft support",
- "Temporary routing anomaly",
- "Somebody was calculating pi on the server",
- "Fat electrons in the lines",
- "Excess surge protection",
- "Floating point processor overflow",
- "Divide-by-zero error",
- "POSIX compliance problem",
- "Monitor resolution too high",
- "Improperly oriented keyboard",
- "Network packets travelling uphill",
- "Decreasing electron flux",
- "radiosity depletion",
- "CPU radiator broken",
- "It works the way the Wang did, what's the problem",
- "Positron router malfunction",
- "Cellular telephone interference",
- "Tectonic stress",
- "piezo-electric interference",
- "(l)user error",
- "Working as designed",
- "Dynamic software linking table corrupted",
- "Heavy gravity fluctuation, move computer to floor rapidly",
- "Secretary plugged hairdryer into UPS",
- "Terrorist activities",
- "Not enough memory, go get system upgrade",
- "Interrupt configuration error",
- "Spaghetti cable cause packet failure",
- "Boss forgot system password",
- "Bank holiday - system operating credits not recharged",
- "Virus attack, luser responsible",
- "Complete Transient Lockout",
- "Bad ether in the cables",
- "Bogon emissions",
- "Change in Earth's rotational speed",
- "Cosmic ray particles crashed through the hard disk platter",
- "Groundskeepers stole the root password",
- "High pressure system failure",
- "Failed trials, system needs redesigned",
- "System has been recalled",
- "Not approved by the FCC",
- "Need to wrap system in aluminum foil to fix problem",
- "Not properly grounded, please bury computer",
- "CPU needs recalibration",
- "System needs to be rebooted",
- "Bit bucket overflow",
- "Descramble code needed from software company",
- "Only available on a need to know basis",
- "Knot in cables caused data stream to become twisted and kinked",
- "Nesting roaches shorted out the ether cable",
- "The file system is full of it",
- "Daemons did it",
- "You're out of memory",
- "There isn't any problem",
- "Unoptimized hard drive",
- "Typo in the code",
- "Yes, yes, its called a design limitation",
- "Look, buddy: Windows 3.1 IS A General Protection Fault.",
- "Support staff hung over, send aspirin and come back LATER.",
- "Someone is standing on the Ethernet cable, causing a kink in the cable",
- "Windows 95 \"feature\"",
- "Runt packets",
- "Password is too complex to decrypt",
- "Electromagnetic energy loss",
- "Budget cuts",
- "Mouse chewed through power cable",
- "Stale file handle",
- "Feature not yet implemented",
- "Internet outage",
- "Pentium FDIV bug",
- "Vendor no longer supports the product",
- "The vendor put the bug there.",
- "SIMM crosstalk.",
- "IRQ dropout",
- "Collapsed Backbone",
- "Power company testing new voltage spike (creation) equipment",
- "Operators on strike due to broken coffee machine",
- "Backup tape overwritten with copy of system manager's favorite CD",
- "UPS interrupted the server's power",
- "The keyboard isn't plugged in",
- "The air conditioning water supply pipe ruptured over the machine room",
- "Root name servers are out of sync",
- "Electro-magnetic pulses from French above ground nuke testing.",
- "Your keyboard's space bar is generating spurious keycodes.",
- "The real TTY's became pseudo TTY's and vice-versa.",
- "The printer thinks its a router.",
- "The router thinks its a printer.",
- "Evil hackers from Serbia.",
- "We just switched to FDDI.",
- "User to computer ratio too high.",
- "User to computer ration too low.",
- "We just switched to Sprint.",
- "Sticky bits on disk."
- "Power Company having EMP problems with their reactor",
- "The ring needs another token",
- "new management",
- "Telnet: Unable to connect to remote host: Connection refused",
- "SCSI Chain over-terminated",
- "It's not plugged in.",
- "Because of network lag due to too many people playing deathmatch",
- "You put the disk in upside down.",
- "Daemons loose in system.",
- "User was distributing pornography on server; system seized by FBI.",
- "Disks spinning backwards - toggle the hemisphere jumper.",
- "New guy cross-connected phone lines with ac power bus.",
- "Had to use hammer to free stuck disk drive heads.",
- "Too few computrons available.",
- "Communications satellite used by the military for star wars.",
- "Party-bug in the Aloha protocol.",
- "Dew on the telephone lines.",
- "Arcserve crashed the server again.",
- "Some one needed the powerstrip, so they pulled the switch plug.",
- "Big to little endian conversion error",
- "Dumb terminal",
- "Zombie processes haunting the computer",
- "Incorrect time synchronization",
- "Defunct processes",
- "Stubborn processes",
- "Non-redundant fan failure ",
- "Monitor VLF leakage",
- "Bugs in the RAID",
- "Root rot",
- "Backbone Scoliosis",
- "Excessive collisions & not enough packet ambulances",
- "le0: no carrier: transceiver cable problem?",
- "Broadcast packets on wrong frequency",
- "Popper unable to process jumbo kernel",
- "NOTICE: alloc: /dev/null: filesystem full",
- "Pseudo-user on a pseudo-terminal",
- "Recursive traversal of loopback mount points",
- "Backbone adjustment",
- "OS swapped to disk",
- "sticktion",
- "Short leg on process table",
- "Multicasts on broken packets",
- "Ether leak",
- "endothermal recalibration",
- "filesystem not big enough for Jumbo Kernel Patch",
- "Loop found in loop in redundant loopback",
- "System consumed all the paper for paging",
- "Permission denied",
- "..Disk or the processor is on fire.",
- "SCSI's too wide.",
- "Proprietary Information.",
- "Just type \'mv * /dev/null\'.",
- "Runaway cat on system.",
- "Did you pay the new Support Fee?",
- "We only support a 1200 BPS connection.",
- "We only support a 28000 BPS connection.",
- "The curls in your keyboard cord are losing electricity.",
- "The monitor needs another box of pixels.",
- "RPC_PMAP_FAILURE",
- "kernel panic: write-only-memory (/dev/wom0) capacity exceeded.",
- "Quantum dynamics are affecting the transistors",
- "Your mail is being routed through Germany ... and they're censoring us.",
- "Only people with names beginning with \'A\' are getting mail this week",
- "We didn't pay the Internet bill and it's been cut off." ,
- "Lightning strikes.",
- "Of course it doesn't work. We've performed a software upgrade.",
- "Change your language to Finnish.",
- "High nuclear activity in your area.",
- "The UPS doesn't have a battery backup.",
- "Recursivity. Call back if it happens again.",
- "Someone thought The Big Red Button was a light switch.",
- "The mainframe needs to rest. It's getting old, you know.",
- "I'm not sure. Try calling the Internet's head office -- it's in the book.",
- "A star wars satellite accidentally blew up the WAN.",
- "Fatal error right in front of screen",
- "Wrong polarity of neutron flow",
- "Lusers learning curve appears to be fractal",
- "We had to turn off that service to comply with the CDA Bill.",
- "Ionization from the air-conditioning",
- "TCP/IP UDP alarm threshold is set too low.",
- "Someone is broadcasting pigmy packets and the router doesn't know how to deal with them.",
- "The new frame relay network hasn't bedded down the software loop transmitter yet. ",
- "Fanout dropping voltage too much, try cutting some of those little traces",
- "Plate voltage too low on demodulator tube",
- "You did wha... oh _dear_....",
- "CPU needs bearings repacked",
- "Too many little pins on CPU confusing it, bend back and forth until 10-20% are \"neatly removed.\"",
- "_Rosin_ core solder? But...",
- "Software uses US measurements, but the OS is in metric...",
- "Too much radiation coming from the soil.",
- "Program load too heavy for processor to lift.",
- "Processes running slowly due to weak power supply",
- "We've run out of licenses",
- "Interference from lunar radiation",
- "Standing room only on the bus.",
- "You need to install an RTFM interface.",
- "That would be because the software doesn't work.",
- "That's easy to fix, but I can't be bothered.",
- "We're upgrading /dev/null",
- "The Usenet news is out of date",
- "Our POP server was kidnapped by a weasel.",
- "It's stuck in the Web.",
- "Your modem doesn't speak English.",
- "All of the packets are empty.",
- "The UPS is on strike.",
- "Neutrino overload on the nameserver",
- "Melting hard drives",
- "Someone has messed up the kernel pointers",
- "The kernel license has expired",
- "It was OK before you touched it.",
- "Bit rot",
- "The static electricity routing is acting up...",
- "Traceroute says that there is a routing problem in the backbone. It's not our problem.",
- "The co-locator cannot verify the frame-relay gateway to the ISDN server.",
- "Electrons on a bender",
- "Telecommunications is upgrading. ",
- "Telecommunications is downgrading.",
- "Telecommunications is downshifting.",
- "Hard drive sleeping. Let it wake up on it's own...",
- "Interference between the keyboard and the chair.",
- "The CPU has shifted, and become decentralized.",
- "Due to the CDA, we no longer have a root account.",
- "You must've hit the wrong anykey.",
- "PCMCIA slave driver",
- "The Token fell out of the ring. Call us when you find it.",
- "The hardware bus needs a new token.",
- "Too many interrupts",
- "Not enough interrupts",
- "The data on your hard drive is out of balance.",
- "Digital Manipulator exceeding velocity parameters",
- "Appears to be a Slow/Narrow SCSI-0 Interface problem",
- "microelectronic Riemannian curved-space fault in write-only file system",
- "Fractal radiation jamming the backbone",
- "Routing problems on the neural net",
- "IRQ-problems with the Un-Interruptable-Power-Supply",
- "CPU-angle has to be adjusted because of vibrations coming from the nearby road",
- "Emissions from GSM-phones",
- "CD-ROM server needs recalibration",
- "Firewall needs cooling",
- "Asynchronous inode failure",
- "Transient bus protocol violation",
- "Incompatible bit-registration operators",
- "Your process is not ISO 9000 compliant",
- "You need to upgrade your VESA local bus to a MasterCard local bus.",
- "The recent proliferation of Nuclear Testing",
-
- };
-
-
- int intCurrentExcuse;
-
- /********************************************************************
- * Basic PilotMain stuff here.
- *
- ********************************************************************/
-
- DWord PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags) {
-
-
- if (cmd == sysAppLaunchCmdNormalLaunch) {
-
- StartApplication();
- EventLoop();
- StopApplication();
-
- }
-
- return 0;
-
- }
-
- /****************************************************************
- * Event Loop Handler
- *
- ****************************************************************/
-
- static void EventLoop(void) {
-
- EventType event;
- Word error;
-
-
- do {
-
- EvtGetEvent(&event, evtWaitForever);
-
-
- if (!SysHandleEvent(&event)) {
-
- if (!MenuHandleEvent(NULL, &event, &error)) {
-
- if (!MainFormHandleEvent(&event)) {
-
- if (!FrmHandleEvent(FrmGetActiveForm(), &event));
- }
- }
- }
-
- } while (event.eType != appStopEvent);
-
- }
-
-
- /*******************************************************************************
- * Stop application and save the date and current excuse for later.
- *
- *******************************************************************************/
-
- static void StopApplication() {
-
- prefs mypref;
-
- mypref.lastExcuse = intCurrentExcuse;
- mypref.version = 1;
- mypref.day = today.day;
-
- PrefSetAppPreferencesV10(appCreatorID, appPrefID, &mypref, sizeof(mypref));
-
-
- }
-
- /******************************************************************************
- * Start Application and display main form. Also checks preferences.
- *
- ******************************************************************************/
-
- static void StartApplication() {
-
- FormPtr frm;
-
- secs = TimGetSeconds();
- DateSecondsToDate(secs, &today);
- readPreferences();
-
- frm = FrmInitForm(formID_main);
- FrmSetActiveForm(frm);
- FrmDrawForm(frm);
- DisplayNewExcuse();
-
- }
-
- /*******************************************************************************
- * Main form handler.
- *
- *******************************************************************************/
- static Boolean MainFormHandleEvent(EventPtr event) {
-
-
- Boolean handled = false;
- FormPtr form;
-
-
- switch (event->eType) {
-
- case ctlEnterEvent:
-
- if (event->data.ctlEnter.controlID == buttonID_newexcuse) {
- handled = true;
- ++intCurrentExcuse;
- DisplayNewExcuse();
- break;
- }
-
- case menuEvent:
-
- if (event->data.menu.itemID == menuitemID_about) {
- handled = true;
- FrmAlert(alertID_about);
- break;
- }
-
-
- }
-
- return handled;
- }
-
- /*************************************************************************
- *
- * Display an excuse from array using intCurrentExcuse as the index.
- * Splits string if too wide to display.
- *
- *************************************************************************/
-
- static void DisplayNewExcuse() {
-
-
- RectangleType rect;
- int center;
-
-
- if (intCurrentExcuse > TOTALEXCUSES) { intCurrentExcuse = 0; }
-
- StrCopy(pline1, excuses[intCurrentExcuse]);
-
- chopper(line1, line2);
- chopper(line2, line3);
-
- rect.extent.x = 160; rect.extent.y = MESSAGE_AT_Y+20;
- rect.topLeft.x = 0; rect.topLeft.y = MESSAGE_AT_Y;
-
- WinEraseRectangle(&rect, 0);
-
- center = ((160-FntCharsWidth(line1, StrLen(line1)))/2);
- WinDrawChars(line1, StrLen(line1) , center , MESSAGE_AT_Y);
-
- if (line2) {
- int center = ((160-FntCharsWidth(line2, StrLen(line2)))/2);
- WinDrawChars(line2, StrLen(line2), center, MESSAGE_AT_Y+10); }
-
- if (line3) {
- int center = ((160-FntCharsWidth(line3, StrLen(line3)))/2);
- WinDrawChars(line3, StrLen(line3), center, MESSAGE_AT_Y+20);
- }
-
- *pline1 = '\0';
- *pline2 = '\0';
- *pline3 = '\0';
- }
-
-
- /*********************************************************************************
- * Checks to see if user has run application before. If not, display
- * proram info and set prefs.
- *
- * Also checks to see if the date has changed, if so it displays a new message.
- *********************************************************************************/
-
- void readPreferences (void) {
-
-
- if (!PrefGetAppPreferencesV10(appCreatorID, appPrefID, &myprefs, sizeof(prefs))) {
-
- FrmAlert(alertID_about);
-
- myprefs.lastExcuse = intCurrentExcuse = SysRandom(0)%TOTALEXCUSES;
- myprefs.version = 1;
- myprefs.day = today.day;
-
- PrefSetAppPreferencesV10(appCreatorID, appPrefID, &myprefs, sizeof(prefs));
-
- }
-
- else
- {
- PrefGetAppPreferencesV10(appCreatorID, appPrefID, &myprefs, sizeof(prefs));
- intCurrentExcuse = myprefs.lastExcuse;
- if (myprefs.day != today.day) {
- intCurrentExcuse++;
- }
- }
-
- }
-
- /********************************************************************************
- * checks source string to see if it needs to be word wrapped. If so, it copies
- * remaining chars to *dest string.
- *
- *********************************************************************************/
-
- void chopper (void *source, void *dest) {
-
- char *myDest = dest;
- char *mySource = source;
- int i =0;
-
- if (StrLen(source) > FntWordWrap(source, WORD_WRAP_AT)) {
-
- i = FntWordWrap(source, WORD_WRAP_AT);
- do {
- *myDest++ = *(mySource+i);
- i++;
- } while (i < StrLen(source));
-
- *(mySource+FntWordWrap(source, WORD_WRAP_AT)) = '\0';
- *myDest = '\0';
- }
-
- }
-
-